package com.dsbj.icardservice.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsbj.common.msg.ResponseMessage;
import com.dsbj.icardservice.entity.Dept;
import com.dsbj.icardservice.entity.Reservation;
import com.dsbj.icardservice.mapper.DeptMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author cjw 2019-09-23
 */
@Service
@Transactional
public class DeptService extends ServiceImpl<DeptMapper, Dept> {

	@Resource
	private DeptMapper deptMapper;
	
	
	/**
	 * 根据deptname模糊查询dept信息。
	 * <p>tips: deptname中亦可传入deptno</p>
	 *
	 * @param
	 * @return
	 * @author cjw 2019-09-23
	 */
	public List<Dept> getDeptByNameDim(String companyno, String deptname){
		List<Dept> list_dept=null;
		QueryWrapper<Dept> queryWrapper=new QueryWrapper<>();
		
		queryWrapper.eq("COMPANYNO",companyno).eq("STATUS",1)
				.and(i->i.like("DEPTNO",deptname).or().like("DEPTNAME",deptname))
				.orderByDesc("CREATE_TIME");
		list_dept=deptMapper.selectList(queryWrapper);
		return list_dept;
	}
	
	














}
